package org.data;

import java.sql.Time;
import java.util.Arrays;
import java.util.List;
import org.h2.jaqu.Table;
import static org.h2.jaqu.Define.*;

/**
 *
 * @author Dmitriy.M.Krasnov
 */
public class ORace extends Race implements Table, TableWithId {

    public Integer id;
    public Integer distance;
    public Time duration;
    public Integer average_pulse;
    public Integer max_pulse;
    public Integer min_pulse;
    public Integer climb;
    public Integer controls_count;
    public String map_link;
    public String description;

    public ORace() {
        // public constructor
    }

    public ORace(Integer id, Integer distance, Time duration, Integer average_pulse, Integer max_pulse, Integer min_pulse, Integer climb, Integer controls_count, String map_link, String description) {
        this.id = id;
        this.distance = distance;
        this.duration = duration;
        this.average_pulse = average_pulse;
        this.max_pulse = max_pulse;
        this.min_pulse = min_pulse;
        this.climb = climb;
        this.controls_count = controls_count;
        this.map_link = map_link;
        this.description = description;
    }

    public void define() {
        tableName("ORace");
        primaryKey(id);
    }

    // test
    private static ORace create(Integer id, Integer distance, Time duration, Integer average_pulse, Integer max_pulse, Integer min_pulse, Integer climb, Integer controls_count, String map_link, String description) {
        return new ORace(id, distance, duration, average_pulse, max_pulse, min_pulse, climb, controls_count, map_link, description);
    }

    // test method
    public static List<ORace> getList() {
        ORace[] list = new ORace[]{
            create(1, 11, new Time(12345), 100, 120, 80, 5, 3, "1", "description"),
            create(2, 15, new Time(54321), 110, 130, 90, 5, 4, "2", "description")
        };
        return Arrays.asList(list);
    }

    @Override
    public String toString() {
        return id.toString();
    }

    public Integer getId() {
        return id;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public Integer getDistance() {
        return distance;
    }

    @Override
    public Time getDuration() {
        return duration;
    }
}
